package sun.cn.common.builder;

import sun.cn.common.cacheDto.proxy.ServiceProxy;

import java.util.Arrays;
import java.util.List;

public class DtoBuilder {

    private DtoCreate create;
    private List<ServiceProxy> proxys;

    private DtoBuilder(){}

    public DtoBuilder setProxy(ServiceProxy ... proxys){
        this.proxys = Arrays.asList(proxys);
        return this;
    }

    public DtoCreate build() {
        return new DtoCreate(proxys);
    }

    public static DtoBuilder newDtoBuilder(){
        return new DtoBuilder();
    }

    public class DtoCreate {

        private List<ServiceProxy> proxys;

        public DtoCreate(List<ServiceProxy> proxys){
            this.proxys = proxys;
        }

        public <T> T getBean(Object obj,Class<T> intface,Class<T> cls){
            return BeanFactory.getBean(obj,intface,cls,this.proxys);
        }

    }
}
